
#include <vector>

class Solution {
 public:
  int removeDuplicates(std::vector<int>& nums)
  {
    int slowIndex = 0;
    int prev;
    for (int fastIndex = 0; fastIndex != nums.size(); ++fastIndex)
    {
      if (slowIndex == 0 || nums[fastIndex] != prev)
      {
        nums[slowIndex++] = nums[fastIndex];
        prev = nums[fastIndex];
      }
    }
    return slowIndex;
  }
};
